package com.scrcu.cloud.wechat.home.endpoint.staff.controller;

import cn.hutool.json.JSONObject;
import com.scrcu.cloud.wechat.home.endpoint.common.model.RestResponse;
import com.scrcu.cloud.wechat.home.endpoint.customer.dto.PreBookInfo;
import com.scrcu.cloud.wechat.home.endpoint.customer.service.IBookService;
import com.scrcu.cloud.wechat.home.endpoint.staff.dto.AssessDto;
import com.scrcu.cloud.wechat.home.endpoint.staff.service.IStaffService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;

@Slf4j
@RestController
@RequestMapping("/staff")
public class StaffController {

    @Resource
    private IStaffService iStaffService;

    @PostMapping("/getSecret")
    public RestResponse getSecret(@RequestParam("appid") String appid){
        return iStaffService.getSecret(appid);
    }

    @PostMapping("/getaccessToken")
    public RestResponse getaccessToken(@RequestParam("appid") String appid){
        return iStaffService.getaccessToken(appid);
    }

    @PostMapping("/getaccessTokenqiye")
    public RestResponse getaccessTokenqiye(@RequestParam("appid") String appid){
        return iStaffService.getaccessTokenqiye(appid);
    }

    @PostMapping("/getInstList")
    public RestResponse getInstList(@RequestParam("accessToken") String accessToken,
                                    @RequestParam("id") String id){
        return iStaffService.getInstList(accessToken,id);
    }

    @PostMapping("/processBook")
    public RestResponse processBook(@RequestParam("bookid") String bookid,
                                    @RequestParam("staffid") String staffid){
        return iStaffService.processBook(bookid,staffid);
    }

    @PostMapping("/submitStaff")
    public RestResponse submitStaff(@RequestParam("openid") String openid,
                                    @RequestParam("oanum") String oanum,
                                    @RequestParam("name") String name,
                                    @RequestParam("map_id") String map_id,
                                    @RequestParam("city") String city,
                                    @RequestParam("area") String area){
        return iStaffService.submitStaff(openid,oanum,name,map_id,city,area);
    }

    @PostMapping("/judgeStaff")
    public RestResponse judgeStaff(@RequestParam("openid") String openid){
        return iStaffService.judgeStaff(openid);
    }




    //关于考核相关

    @PostMapping("/getGroupAdmin")
    public RestResponse getGroupAdmin(@RequestParam("openid") String openid){
        return iStaffService.getGroupAdmin(openid);
    }
    @PostMapping("/getGroup")
    public RestResponse getGroup(@RequestParam("openid") String openid){
        return iStaffService.getGroup(openid);
    }

    @PostMapping("/getMember")
    public RestResponse getMember(@RequestParam("openid") String openid,
                                  @RequestParam("groupid") String groupid){
        return iStaffService.getMember(openid,groupid);
    }

    @PostMapping("/getMemberAdmin")
    public RestResponse getMemberAdmin(@RequestParam("openid") String openid,
                                  @RequestParam("groupid") String groupid,
                                       @RequestParam("date") String date){
        return iStaffService.getMemberAdmin(openid,groupid,date);
    }

    @PostMapping("/getTopiclist")
    public RestResponse getTopiclist(@RequestParam("openid") String openid,
                                  @RequestParam("groupid") String groupid){
        return iStaffService.getTopiclist(openid,groupid);
    }

    @PostMapping("/getTopic")
    public RestResponse getTopic(@RequestParam("openid") String openid,
                                     @RequestParam("topicid") String topicid){
        return iStaffService.getTopic(openid,topicid);
    }

    @PostMapping("/getTopiclistAdmin")
    public RestResponse getTopiclistAdmin(@RequestParam("openid") String openid,
                                     @RequestParam("groupid") String groupid,
                                          @RequestParam("date") String date){
        return iStaffService.getTopiclistAdmin(openid,groupid,date);
    }

    @PostMapping("/getTopicsWithDetail")
    public RestResponse getTopicsWithDetail(@RequestParam("openid") String openid,
                                            @RequestParam("memberid") String memberid,
                                          @RequestParam("groupid") String groupid,
                                          @RequestParam("date") String date){
        return iStaffService.getTopicsWithDetail(openid,memberid,groupid,date);
    }



    @PostMapping("/submitForm")
    @ResponseBody
    public RestResponse submitForm(@RequestBody JSONObject assesses){
        return iStaffService.submitForm(assesses);
    }

    @PostMapping("/clearAssess")
    public RestResponse clearAssess(@RequestParam("openid") String openid,
                                     @RequestParam("groupid") String groupid,
                                    @RequestParam("memberid") String memberid){
        return iStaffService.clearAssess(openid,groupid,memberid);
    }

    @PostMapping("/getTopiclistDetail")
    public RestResponse getTopiclistDetail(@RequestParam("openid") String openid,
                                    @RequestParam("groupid") String groupid,
                                    @RequestParam("memberid") String memberid){
        return iStaffService.getTopiclistDetail(openid,groupid,memberid);
    }

    @PostMapping("/openAssGroup")
    public RestResponse openAssGroup(@RequestParam("openid") String openid,
                                           @RequestParam("groupid") String groupid,
                                           @RequestParam("date") String date){
        return iStaffService.openAssGroup(openid,groupid,date);
    }

    @PostMapping("/closeAssGroup")
    public RestResponse closeAssGroup(@RequestParam("openid") String openid,
                                     @RequestParam("groupid") String groupid,
                                     @RequestParam("date") String date){
        return iStaffService.closeAssGroup(openid,groupid,date);
    }

    @PostMapping("/getAssGroup")
    public RestResponse getAssGroup(@RequestParam("openid") String openid,
                                      @RequestParam("groupid") String groupid,
                                      @RequestParam("date") String date){
        return iStaffService.getAssGroup(openid,groupid,date);
    }


    @GetMapping("/extractReport")
    public RestResponse extractReport(@RequestParam("openid") String openid,
                                      @RequestParam("groupid") String groupid,
                                      @RequestParam("date") String date, HttpServletResponse response){
        return iStaffService.extractReport(openid,groupid,date,response);
    }


    @PostMapping("/deleteTopic")
    public RestResponse deleteTopic(@RequestParam("openid") String openid,
                                      @RequestParam("topicid") String topicid){
        return iStaffService.deleteTopic(openid,topicid);
    }

    @PostMapping("/addTopic")
    public RestResponse addTopic(@RequestParam("openid") String openid,
                                 @RequestParam("groupid") String groupid,
                                 @RequestParam("date") String date,
                                 @RequestParam("topic_desc") String topic_desc,
                                 @RequestParam("topic_type") String topic_type){
        return iStaffService.addTopic(openid,groupid,date,topic_desc,topic_type);
    }

    @PostMapping("/modifyTopic")
    public RestResponse modifyTopic(@RequestParam("openid") String openid,
                                    @RequestParam("topicid") String topicid,
                                 @RequestParam("topic_desc") String topic_desc,
                                 @RequestParam("topic_type") String topic_type){
        return iStaffService.modifyTopic(openid,topicid,topic_desc,topic_type);
    }

}
